<?php 
class Front_Print_Generic extends System_Db_Generic  {
	public function getPreauthId(){
		$db = Zend_Registry :: get("db");
		$statement = $db->prepare('select dbo.FN_Preauth_GenID () as preauth_id');
		$statement->execute();
		$results = $statement->fetchAll();
		return $results['0']['preauth_id'];
	}
	public function getPolicyById($policy_id){
		if(!$policy_id) return;
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_queryByPolicyId '$policy_id'";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		foreach ($results as $key=>$value){
			$results[$key]['effective'] = getDateFormat2($results[$key]['effective']);
			$results[$key]['expiry'] = getDateFormat2($results[$key]['expiry']);
			$results[$key]['me_cover'] = number_format($results[$key]['me_cover'],2,'.',',');
			$results[$key]['mc_cover'] = number_format($results[$key]['mc_cover'],2,'.',',');
		}
		return $results['0'];
	}
	public function getPaInfo($policy_id){
		if(!$policy_id) return;
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_policy_get_info '$policy_id'";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		return $results['0'];
	}
	public function getPaClaim($policy_id){
		if(!$policy_id) return;
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_edc_getPaClaim '$policy_id'";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		foreach ($results as $key=>$value){
			$results[$key]['acc_date'] = getDateFormat2($results[$key]['acc_date']);
			$results[$key]['paid'] = number_format($results[$key]['paid'],2,'.',',');
		}
		return $results;
	}
	public function getErClaim($policy_id){
		if(!$policy_id) return;
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_edc_getErClaim '$policy_id'";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		foreach ($results as $key=>$value){
			$results[$key]['acc_date'] = getDateFormat2($results[$key]['acc_date']);
			$results[$key]['paid'] = number_format($results[$key]['paid'],2,'.',',');
		}
		return $results;
	}
	public function getPlan2catByPlanId($plan_id){
		if(!$plan_id) return;
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_getPlan2catByPlanid '$plan_id'";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		return $results['0'];
	}
}
?>